package com.web;


import com.pojo.dto.Message;
import com.pojo.entity.CVideo;
import com.pojo.vo.CVideoVo;
import com.service.CVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CVideoController {
    @Autowired
    CVideoService cVideoService;

    @PostMapping("/selectVideoList")//视频全部查询
    public Message<List<CVideoVo>> selectAllVideo() {
        return cVideoService.videoList();
    }

    @PostMapping("/selectVideo")//视频单个查询
    public Message<CVideoVo> selectVideo(CVideoVo cVideoVo) {
        return cVideoService.selectOneVideo(cVideoVo);
    }
    @PostMapping("/selectVideoByUser")//视频单个查询不可用
    public Message<List<CVideoVo>> selectVideoByUser(CVideoVo cVideoVo) {
        return cVideoService.videoListByUser(cVideoVo);
    }

    @PostMapping("/updateVideo")//修改视频，修改点赞数和评论数
    public Message<CVideoVo> updateRole(CVideoVo cVideoVo) {
        return cVideoService.updateVideo(cVideoVo);
    }

    @PostMapping("/addVideo")//上传视频
    public Message<CVideoVo> addRole(CVideoVo cVideoVo) {
        return cVideoService.add(cVideoVo);
    }

    @PostMapping("/deleteVideo")//单个删除视频
    public Message<String> deleteRole(CVideoVo cVideoVo) {
        return cVideoService.deleteVideo(cVideoVo);
    }

    @PostMapping("/deleteVideoList")//批量删除视频
    public Message<String> deleteRoleList(List<CVideoVo> videos) {
        return cVideoService.deleteVideoList(videos);
    }


}
